package cn.itcast.utils;

import com.sun.org.apache.bcel.internal.classfile.Code;

import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.Properties;

public class CityCodeUtils {

    private static Properties properties = new Properties();
    public static String DEFAULT_CODE = "101010100";

    private CityCodeUtils() {

    }

    static  {
        ClassLoader classLoader = CityCodeUtils.class.getClassLoader();
        InputStream is = classLoader.getResourceAsStream("citycodes.properties");
        try {
            properties.load(new InputStreamReader(is,"UTF-8"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static String getCityCode(String cityName) {
        String code = properties.getProperty(cityName, "101010100");
        return code;
    }
}
